package enumandlambda;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author shkstart
 * 线程池用法2：带缓存的线程池
 * @create 2022-12-07-21:50
 */
public class ThreadPoolDemo4 {
    public static void main(String[] args) {
        //创建线程池
        ExecutorService service = Executors.newCachedThreadPool();
        for (int i = 0; i < 100; i++) {
            int finalI = i;
            service.submit(()->{
                System.out.println("i:"+finalI+"|县线程名称"+
                        Thread.currentThread().getName());
            });
        }
    }
}
